|
|
|
|
|
|
|
SELECT COUNT(Units) AS UnitCount,
AVG(Units) AS UnitAvg,
SUM(Units) AS UnitSum,
MIN(Units) AS UnitMin,
MAX(Units) AS UnitMax
FROM BookSales
WHERE Qtr = 1 |
|
|
|
|
|
|
|
|
Figure 8.16.
Using the WHERE clause to limit
the scope of aggregate functions. |
|
|
|
|
|
|
|
|
Using Visual Basic Functions in a SELECT Statement |
|
|
|
|
|
|
|
|
When you call the Microsoft Access Jet database engine from within a Visual Basic program, you can use any valid Visual Basic functions as part of the SQL statement. For example, if you want to create a result set with a column that holds only the first three characters of a field in the underlying table, you could use the Visual Basic Left$ function as part of your column list in the SELECT_FROM statement, in the following line (see Figure 8.17): |
|
|
|
|
|
|
|
|
SELECT Left$(Name,3), Name
FROM Authors |
|
|
|
|
|
|
|
|
Figure 8.17.
Using Visual Basic functions in an SQL statement. |
|
|
|
|
|